All Questions
Tagged with javascriptwp-enqueue-script
221 questions
2votes
0answers
101views
How to Use Webpack with WordPress Script Modules and Enqueue a Custom Class
I am working on a WordPress project using version 6.5, which introduced support for JavaScript modules. I have a parent theme that exports a JavaScript class, and I want to import this class in a ...
0votes
1answer
23views
How can I access custom data fetched from posts in a javascript script?
I am trying to fetch the lat, long data from custom fields in my posts in order to make a map layer with them (openlayers). I added custom long and lat fields to each post I created a function to ...
2votes
1answer
312views
Wordpress Gutenberg Custom Block the viewScript does not get loaded on the frontend when my block is inserted
I recently developed a custom Gutenberg block by utilizing the @wordpress/create-block package, which effectively generated a full plugin framework. I simply needed to tweak some existing files to get ...
1vote
1answer
272views
Custom gutenberg block refuses to load viewScript and I don't know why
I've been struggling with this for hours. I used the @wordpress/create-block package to generate a template for me to create my first block. I've managed to create a hero block with an image uploader ...
1vote
1answer
488views
How to securely set dynamic HTML content with JavaScript?
Description I have implemented a frontend script that gets a few text options from the server via wp_add_inline_script. When the user does an action the content should dynamically change to one of the ...
0votes
0answers
45views
Bootstrap bundle present in page source but not working
I'm facing a very peculiar issue where the bootstrap css is working fine but the js is not working. The js shows in the page source. I am using cdn but I have also tried by downloading the bundle and ...
0votes
0answers
151views
wp_enqueue_script JS code runs too late (after user begins interacting)
The issue is that we need to replace some HTML based on the user's user agent string but by the time the JS code is loaded and runs, the user is already interacting with the page. Is there some way to ...
0votes
0answers
193views
JS / jQuery in Elementor pages vs JS file
I have a lot of JavaScript and jQuery functions that are all working fine, but it's quite fragmented and hard to maintain as some are in Elementor HTML widgets, others in specific Pho functions annd ...
1vote
0answers
167views
Is there a way to check for an attribute of a script when using script_loader_tag?
The block of code adds the attribute async to a array of Javascript files. Is there a way to check if the files have already have the attribute assigned and if yes, to skip it? function async_scripts( ...
0votes
1answer
103views
How to load Javascript code or functions.php later in a child theme?
I'm placing some JS code in functions.php in my child theme but it loads first than anything else. Thus, I'm trying to get it to load later than the rest cos it needs Jquery. I tried enqueuing WP's ...
0votes
1answer
1kviews
Add type to enqueued script inside plugin
So I don't know if this is possible, but I have a question - We are integrating OneTrust and one of the requirements was to change <script type='text/javascript'> to <script type='text/plain&...
1vote
1answer
1kviews
Dequeue / Deregister script and replace it with a new plugin
I think I've read a dozen posts about dequeuing and deregistering scripts, but I haven't been able to make it work properly in my situation. My situation: The "uListing" plugins are part of ...
0votes
1answer
98views
Do I just put the html in a page when enqueueng or do I also have to reference js file from the html page [closed]
I am trying to get my javascript to work in my page, but I have always just put the html on the actual page, but now am wondering if I am supposed to put the <script src before the html as well to ...
0votes
2answers
705views
How can I remove the Wordpress-Version (?ver=5.x) from my plugin
I am working on my first plugin that adds a external script to the footer. Wordpress automatically adds the version number at the end, which I'm trying to remove. What I have so far: add_action('...
2votes
1answer
3kviews
Can the index.asset.php file be used with the enqueue_block_editor_assets action?
I'm developing a plugin that registers a PluginDocumentSettingPanel in Gutenberg. As this is not a block, I cannot use the register_block_type function to add its assets, so I have to employ the ...